<template>
  <div>
    <div class="header" id="header">
      <router-link to="/percen">
        <div class="header_back">
          <div class="header_back_r"></div>
        </div>
      </router-link>
      <div id="head-title">登录</div>
      <router-link to="/zhuce" class="gb-head-rightwrap" data-ajax="false">
        <div class="header_right">
          注册
        </div>
      </router-link>
    </div>
    <van-form @submit="onSubmit">
      <van-field
        v-model="username"
        name="name"
        label="用户名"
        placeholder="用户名"
        :rules="[{ required: true, message: '请填写用户名' }]"
      />
      <van-field
        v-model="password"
        type="password"
        name="password"
        label="密码"
        placeholder="密码"
        :rules="[{ required: true, message: '请填写密码' }]"
      />
      <div style="margin: 16px">
        <van-button round block type="info" native-type="submit"
          >登录</van-button
        >
      </div>
    </van-form>
  </div>
</template>

<script>
import {mapActions} from 'vuex'
export default {
  data() {
    return {
      username: "",
      password: "",
    };
  },
  methods: {
    ...mapActions({
      handaddActuon:'percen/handaddAction'
    }),
    onSubmit(values) {
      // this.$store.commit("percen/handadd", values);
      this.handaddActuon(values)
      setTimeout(() => {
        this.$router.push('/percen')
      }, 500);
      
    },
  },
};
</script>

<style lang="less" scoped>
.van-form {
  margin-top: 70px;
}
</style>